App({
  onLaunch() {
    const token = wx.getStorageSync('token') || null;
    const riderId = wx.getStorageSync('riderId') || null;

    this.globalData.ridertoken = token;
    this.globalData.riderId = riderId;

    if (!token) {
      // token不存在，跳转登录页
      wx.reLaunch({
        url: '/pages/logs/logs'
      });
    }

    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },

  globalData: {
    userInfo: null,
    locationKey: 'IKWBZ-CPGKQ-JD75Z-4AIS4-APLHH-7PBGT', // 你的腾讯位置服务 Key
    userIPInfo: 'https://dulongyucun.ttcxy.top',
    riderId: null,
    ridertoken: null,
  }
})
